<template>
  <img src="./img/bg.png" alt="" class="bg" />
  <div class="topSitting">头部占位</div>
  <!-- 公积金 -->
  <div class="incomeInfo" v-for="item in gjjList" :key="item.id">
    <div class="infoTitle">公积金信息</div>
    <img src="./img/daban_bg.png" alt="" class="infoTitleBg" />
    <div class="infoTips">图片数量(4)</div>
    <div class="infoIem">
      <div class="title">缴存类型</div>
      <div class="value">{{ item.depositType }}</div>
    </div>
    <div class="infoIem">
      <div class="title">缴存单位</div>
      <div class="value">{{ item.depositoryCompany }}</div>
    </div>
    <div class="infoIem">
      <div class="title">单位性质</div>
      <div class="value">{{ item.compayProp }}</div>
    </div>
    <div class="infoIem">
      <div class="title">月缴存额</div>
      <div class="value">{{ item.monthlyDeposit + "元" }}</div>
    </div>
    <div class="infoIem">
      <div class="title">账户余额</div>
      <div class="value">{{ item.accountBalance + "元" }}</div>
    </div>
    <div class="bottomBtnArea">
      <div class="btn delete" @click="deletegjj(item.id)">删除</div>
      <div class="btn check" @click="checkgjj(item.id)">查看</div>
    </div>
  </div>
  <!-- 社保 -->
  <div class="incomeInfo" v-for="item in sbList" :key="item.id">
    <div class="infoTitle">社保信息</div>
    <img src="./img/daban_bg.png" alt="" class="infoTitleBg" />
    <div class="infoTips">图片数量(4)</div>
    <div class="infoIem">
      <div class="title">社保缴存单位</div>
      <div class="value">{{ item.depositoryCompany }}</div>
    </div>
    <div class="infoIem">
      <div class="title">社保缴存基数</div>
      <div class="value">{{ item.securityBase }}</div>
    </div>
    <div class="infoIem">
      <div class="title">单位性质</div>
      <div class="value">{{ item.compayProp }}</div>
    </div>
    <div class="infoIem">
      <div class="title">当前缴存状态</div>
      <div class="value">{{ item.currentDepositStatus }}</div>
    </div>
    <div class="infoIem">
      <div class="title">是否断缴</div>
      <div class="value">{{ item.isBreak }}</div>
    </div>
    <div class="bottomBtnArea">
      <div class="btn delete" @click="deletesb(item.id)">删除</div>
      <div class="btn check" @click="checksb(item.id)">查看</div>
    </div>
  </div>
  <!-- 个税 -->
  <div class="incomeInfo" v-for="item in gsList" :key="item.id">
    <div class="infoTitle">个税信息</div>
    <img src="./img/daban_bg.png" alt="" class="infoTitleBg" />
    <div class="infoTips">图片数量(4)</div>
    <div class="infoIem">
      <div class="title">缴存单位</div>
      <div class="value">{{ item.depositoryCompany }}</div>
    </div>
    <div class="infoIem">
      <div class="title">单位性质</div>
      <div class="value">{{ item.compayProp }}</div>
    </div>
    <div class="infoIem">
      <div class="title">上年度收入合计</div>
      <div class="value">{{ item.lastYearTotalIncome }}</div>
    </div>
    <div class="infoIem">
      <div class="title">本年收入合计</div>
      <div class="value">{{ item.yearTotalIncome }}</div>
    </div>
    <div class="infoIem">
      <div class="title">本年度收入月份</div>
      <div class="value">{{ item.incomeMonth }}</div>
    </div>
    <div class="bottomBtnArea">
      <div class="btn delete" @click="deletegs(item.id)">删除</div>
      <div class="btn check" @click="checkgs(item.id)">查看</div>
    </div>
  </div>
  <div class="addArea" @click="incomeShow = true">
    <img src="./img/new_icon.png" alt="" class="icon" />
    <div>新增</div>
  </div>
  <up-picker
    :show="incomeShow"
    :columns="incomeCols"
    :defaultIndex="[0]"
    title="收入信息分类"
    @cancel="incomeShow = false"
    @confirm="checkIncome"
  ></up-picker>
</template>

<script setup>
import { ref, reactive } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import * as http from "../../utils/http";
const sbList = reactive([]);
const gjjList = reactive([]);
const gsList = reactive([]);
let param = null;
onLoad((option) => {
  param = JSON.parse(option.value);
  http.creditSocialSecurityList({ orderId: param.orderId }).then((res) => {
    sbList.push(...res.data);
  });
  http.creditProvidentFundList({ orderId: param.orderId }).then((res) => {
    gjjList.push(...res.data);
  });
  http.creditPersonalTaxList({ orderId: param.orderId }).then((res) => {
    gsList.push(...res.data);
  });
});
// 公积金删除
const deletegjj = (id) => {
  http
    .creditProvidentFundDelete({ id })
    .then((res) => {
      wx.showToast({
        title: "删除成功",
        icon: "none",
        duration: 1000,
        mask: true,
      });
    })
    .catch((err) => {
      wx.showToast({
        title: "删除失败",
        icon: "none",
        duration: 1000,
        mask: true,
      });
    });
};
// 社保删除
const deletesb = (id) => {
  http
    .creditSocialSecurityDelete({ id })
    .then((res) => {
      wx.showToast({
        title: "删除成功",
        icon: "none",
        duration: 1000,
        mask: true,
      });
    })
    .catch((err) => {
      wx.showToast({
        title: "删除失败",
        icon: "none",
        duration: 1000,
        mask: true,
      });
    });
};
// 个税删除
const deletegs = (id) => {
  http
    .creditPersonalTaxDelete({ id })
    .then((res) => {
      wx.showToast({
        title: "删除成功",
        icon: "none",
        duration: 1000,
        mask: true,
      });
    })
    .catch((err) => {
      wx.showToast({
        title: "删除失败",
        icon: "none",
        duration: 1000,
        mask: true,
      });
    });
};
// 公积金查看
const checkgjj = (id) => {
  let param = {
    isCheck: true,
    id,
  };
  wx.navigateTo({
    url: "../gjjInfo/gjjInfo?value=" + JSON.stringify(param),
  });
};
// 社保查看
const checksb = (id) => {
  let param = {
    isCheck: true,
    id,
  };
  wx.navigateTo({
    url: "../sbInfo/sbInfo?value=" + JSON.stringify(param),
  });
};
// 个税查看
const checkgs = (id) => {
  let param = {
    isCheck: true,
    id,
  };
  wx.navigateTo({
    url: "../gsInfo/gsInfo?value=" + JSON.stringify(param),
  });
};
// 新增跳转
const incomeShow = ref(false);
const incomeCols = reactive([["公积金信息", "社保信息", "个税详细"]]);
const checkIncome = (e) => {
  incomeShow.value = false;
  let params = {
    isCheck: false,
    orderId: param.orderId,
  };
  if (e.value[0] === "公积金信息") {
    wx.navigateTo({
      url: "../gjjInfo/gjjInfo?value=" + JSON.stringify(params),
    });
  } else if (e.value[0] === "社保信息") {
    wx.navigateTo({
      url: "../sbInfo/sbInfo?value=" + JSON.stringify(params),
    });
  } else {
    wx.navigateTo({
      url: "../gsInfo/gsInfo?value=" + JSON.stringify(params),
    });
  }
};
</script>

<style scoped lang="scss">
.bg {
  width: 750rpx;
  height: 863rpx;
  position: absolute;
  left: 0;
  top: 0;
  z-index: -999999;
}
.topSitting {
  height: 50rpx;
  opacity: 0;
}
.incomeInfo {
  margin: 30rpx 28rpx;
  background-color: #fff;
  border-radius: 16rpx;
  padding: 0 30rpx;
  padding-top: 112rpx;
  padding-bottom: 153rpx;
  position: relative;
  font-size: 28rpx;
  box-shadow: 0rpx 4rpx 13rpx 0rpx #e0e4ff;
  .infoTitle {
    width: 260rpx;
    height: 45rpx;
    line-height: 45rpx;
    text-align: center;
    font-size: 28rpx;
    color: #fff;
    position: absolute;
    left: 50%;
    transform: translate(-50%);
    top: 0;
    z-index: 99;
  }
  .infoTitleBg {
    width: 260rpx;
    height: 45rpx;
    position: absolute;
    left: 50%;
    transform: translate(-50%);
    top: 0;
    z-index: 9;
  }
  .infoTips {
    position: absolute;
    left: 50%;
    transform: translate(-50%);
    top: 68rpx;
    color: #3277f2;
  }
  .infoIem {
    height: 90rpx;
    border-bottom: 1rpx solid #eeeeee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .title {
      color: #666666;
    }
    .value {
      color: #999999;
    }
  }
  .bottomBtnArea {
    display: flex;
    position: absolute;
    left: 50%;
    bottom: 46rpx;
    transform: translate(-50%);
    .btn {
      width: 153rpx;
      height: 60rpx;
      line-height: 60rpx;
      text-align: center;
      border-radius: 29rpx;
      margin: 0 15rpx;
    }
    .delete {
      color: #ff4545;
      border: 1rpx solid #ff3737;
    }
    .check {
      color: #3277f2;
      border: 1rpx solid #598bdc;
    }
  }
}
.addArea {
  height: 150rpx;
  margin: 30rpx 24rpx;
  border: 1rpx dashed #3483fb;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;
  border-radius: 12rpx;
  font-size: 24rpx;
  color: #2f80fb;
  .icon {
    width: 30rpx;
    height: 30rpx;
    margin-right: 30rpx;
  }
}
</style>
